package com.eastfair.notice.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.eastfair.core.base.entity.Entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import static com.eastfair.core.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;
import com.eastfair.annotation.model.EchoVO;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * Im聊天对话内容表
 * </p>
 *
 * @author liuxiaobai
 * @since 2021-08-30
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("c_im_record")
@ApiModel(value = "ImRecord", description = "Im聊天对话内容表")
@AllArgsConstructor
public class ImRecord extends Entity<Long> implements EchoVO {

    private static final long serialVersionUID = 1L;
    @TableField(exist = false)
    private Map<String, Object> echoMap = new HashMap<>();
    @ApiModelProperty(value = "")
    @NotNull(message = "请填写")
    @TableField(value = "project_id")
    @Excel(name = "")
    private Long projectId;

    @ApiModelProperty(value = "")
    @TableField(value = "exhibition_id")
    @Excel(name = "")
    private Long exhibitionId;

    /**
     * 对话唯一code
     */
    @ApiModelProperty(value = "对话唯一code")
    @NotEmpty(message = "请填写对话唯一code")
    @Size(max = 40, message = "对话唯一code长度不能超过40")
    @TableField(value = "unique_code", condition = LIKE)
    @Excel(name = "对话唯一code")
    private String uniqueCode;

    /**
     * 发送人user_account_id
     */
    @ApiModelProperty(value = "发送人user_account_id")
    @NotNull(message = "请填写发送人user_account_id")
    @TableField(value = "from_user_id")
    @Excel(name = "发送人user_account_id")
    private Long fromUserId;

    /**
     * 发送此条消息时的身份（ACTOR、VISITOR）
     */
    @ApiModelProperty(value = "发送此条消息时的身份（ACTOR、VISITOR）")
    @Size(max = 32, message = "发送此条消息时的身份（ACTOR、VISITOR）长度不能超过32")
    @TableField(value = "from_user_type", condition = LIKE)
    @Excel(name = "发送此条消息时的身份（ACTOR、VISITOR）")
    private String fromUserType;

    /**
     * 接收人user_account_id
     */
    @ApiModelProperty(value = "接收人user_account_id")
    @NotNull(message = "请填写接收人user_account_id")
    @TableField(value = "to_user_id")
    @Excel(name = "接收人user_account_id")
    private Long toUserId;

    /**
     * 消息类型 TIMTextElem(文本消息)
     */
    @ApiModelProperty(value = "消息类型 TIMTextElem(文本消息)")
    @Size(max = 32, message = "消息类型 TIMTextElem(文本消息)长度不能超过32")
    @TableField(value = "type", condition = LIKE)
    @Excel(name = "消息类型 TIMTextElem(文本消息)")
    private String type;

    /**
     * 消息内容
     */
    @ApiModelProperty(value = "消息内容")
    @Size(max = 65535, message = "消息内容长度不能超过65535")
    @TableField(value = "content", condition = LIKE)
    @Excel(name = "消息内容")
    private String content;

    /**
     * 自定义消息数据
     */
    @ApiModelProperty(value = "自定义消息数据")
    @Size(max = 65535, message = "自定义消息数据长度不能超过65535")
    @TableField(value = "custom_data", condition = LIKE)
    @Excel(name = "自定义消息数据")
    private String customData;

    /**
     * 是否被撤回
     */
    @ApiModelProperty(value = "是否被撤回")
    @TableField(value = "flag_bits")
    @Excel(name = "是否被撤回", replace = {"是_true", "否_false", "_null"})
    private Boolean flagBits;

    /**
     * 是否生效(默认1：可用 0:不可用)
     */
    @ApiModelProperty(value = "是否生效(默认1：可用 0:不可用)")
    @TableField(value = "is_enable")
    @Excel(name = "是否生效(默认1：可用 0:不可用)")
    private Integer isEnable;

    /**
     * 是否删除(默认0：未删除 1:已删除)
     */
    @ApiModelProperty(value = "是否删除(默认0：未删除 1:已删除)")
    @TableField(value = "is_delete")
    @Excel(name = "是否删除(默认0：未删除 1:已删除)")
    private Integer isDelete;


    @Builder
    public ImRecord(Long id, Long createdBy, LocalDateTime createTime, Long updatedBy, LocalDateTime updateTime, 
                    Long projectId, Long exhibitionId, String uniqueCode, Long fromUserId, String fromUserType, 
                    Long toUserId, String type, String content, String customData, Boolean flagBits, Integer isEnable, Integer isDelete) {
        this.id = id;
        this.createdBy = createdBy;
        this.createTime = createTime;
        this.updatedBy = updatedBy;
        this.updateTime = updateTime;
        this.projectId = projectId;
        this.exhibitionId = exhibitionId;
        this.uniqueCode = uniqueCode;
        this.fromUserId = fromUserId;
        this.fromUserType = fromUserType;
        this.toUserId = toUserId;
        this.type = type;
        this.content = content;
        this.customData = customData;
        this.flagBits = flagBits;
        this.isEnable = isEnable;
        this.isDelete = isDelete;
    }

}
